package skewreduce.lib;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class PhysicsParticle extends Point3D implements IPhysicsParticle {
	protected float vx;
	protected float vy;
	protected float vz;
	protected float mass;
	protected float phi;
	
	public PhysicsParticle(IPhysicsParticle p) {
		super(p);
		vx = p.getVx();
		vy = p.getVy();
		vz = p.getVz();
		mass = p.getMass();
		phi = p.getPhi();
	}

	public PhysicsParticle() {
	}
	
	public void set(IPhysicsParticle p) {
		x = p.getX();
		y = p.getY();
		z = p.getZ();
		vx = p.getVx();
		vy = p.getVy();
		vz = p.getVz();
		mass = p.getMass();
		phi = p.getPhi();
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		super.readFields(in);
		vx = in.readFloat();
		vy = in.readFloat();
		vz = in.readFloat();
		mass = in.readFloat();
		phi = in.readFloat();
	}

	@Override
	public void write(DataOutput out) throws IOException {
		super.write(out);
		out.writeFloat(vx);
		out.writeFloat(vy);
		out.writeFloat(vz);
		out.writeFloat(mass);
		out.writeFloat(phi);
	}
	
	public static PhysicsParticle read(DataInput in) throws IOException {
		PhysicsParticle o = new PhysicsParticle();
		o.readFields(in);
		return o;
	}
	
	public void setMass(float v) { mass = v; }
	public void setPhi(float v) { phi = v; }
	public void setVx(float v) { vx = v; }
	public void setVy(float v) { vy = v; }
	public void setVz(float v) { vz = v; }

	@Override
	public float getMass() {
		return mass;
	}

	@Override
	public float getPhi() {
		return phi;
	}

	@Override
	public float getVx() {
		return vx;
	}

	@Override
	public float getVy() {
		return vy;
	}

	@Override
	public float getVz() {
		return vz;
	}

}
